package service.impl;

import bean.Student;
import dao.StudentDao;
import service.StudentService;

import java.util.List;

/**
 * @author HLF
 * @version V1.0
 * @package service.impl
 * @date 2021/10/19 20:47
 */

public class StudentServiceImpl implements StudentService {

    //定义StudentDao的引用类型属性
    private StudentDao studentDao;

    //使用set注入（设值注入）为studentDao属性赋值
    public void setStudentDao(StudentDao studentDao) {
        this.studentDao = studentDao;
    }

    @Override
    public List<Student> queryAllStudents() {
        List<Student> list = studentDao.selectStudents();
        return list;
    }

    @Override
    public Student findStudent(Integer id) {
        Student student = studentDao.selectStudentById(id);
        return student;
    }

    @Override
    public int addStudent(Student student) {
        int i = studentDao.insertStudent(student);
        return i;
    }

    @Override
    public int modifyStudent(Student student) {
        int i = studentDao.updateStudent(student);
        return i;
    }

    @Override
    public int removeStudent(Integer id) {
        int i = studentDao.deleteStudentById(id);
        return i;
    }
}
